package com.qf.springclold.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * projectName: SpringCloud2
 *
 * @author dongshihao
 * Date:2021/9/15   20:03
 * description:
 */
@RestController
public class TestController {

    @Autowired
    private RestTemplate restTemplate;




    @GetMapping("/consumer/test")
    public String test(){
//        //1.基于服务名字获取服务信息
//        InstanceInfo provider = eurekaClient.getNextServerFromEureka("PROVIDER", false);
//        String ipAddr = provider.getIPAddr();
//        int port = provider.getPort();

        String result = restTemplate.getForObject("http://PROVIDER/provider/test", String.class);
        return "Hello Consumer Test And "  + result;
    }

}
